<script setup lang="ts">
import { onMounted, onBeforeUnmount } from 'vue'
import IndexPage from './body/index.vue'

function handleBeforeUnload(e: BeforeUnloadEvent) {
  e.preventDefault()
  e.returnValue = '确定要离开此页面吗？未保存的更改可能会丢失。'
}

onMounted(() => {
  window.addEventListener('beforeunload', handleBeforeUnload)
})

onBeforeUnmount(() => {
  window.removeEventListener('beforeunload', handleBeforeUnload)
})
</script>

<template>
  <IndexPage />
</template>

